package cn.code.mycloud.module.system.dal.mysql.aqi;

import java.util.*;

import cn.code.mycloud.framework.common.pojo.PageResult;
import cn.code.mycloud.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.code.mycloud.framework.mybatis.core.mapper.BaseMapperX;
import cn.code.mycloud.framework.security.core.LoginUser;
import cn.code.mycloud.framework.security.core.util.SecurityFrameworkUtils;
import cn.code.mycloud.module.system.dal.dataobject.aqi.AqiDO;
import cn.code.mycloud.module.system.service.permission.PermissionService;
import org.apache.ibatis.annotations.Mapper;
import cn.code.mycloud.module.system.controller.admin.aqi.vo.*;

import javax.annotation.Resource;

/**
 * AQI Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface AqiMapper extends BaseMapperX<AqiDO> {

    default PageResult<AqiDO> selectPage(AqiPageReqVO reqVO) {

        return selectPage(reqVO, new LambdaQueryWrapperX<AqiDO>()
                .eqIfPresent(AqiDO::getUserId, reqVO.getUserId())
                .likeIfPresent(AqiDO::getUserName, reqVO.getUserName())
                .eqIfPresent(AqiDO::getGridUserId, reqVO.getGridUserId())
                .likeIfPresent(AqiDO::getGridUserName, reqVO.getGridUserName())
                .likeIfPresent(AqiDO::getName, reqVO.getName())
                .eqIfPresent(AqiDO::getPm25, reqVO.getPm25())
                .eqIfPresent(AqiDO::getSo2, reqVO.getSo2())
                .eqIfPresent(AqiDO::getCo, reqVO.getCo())
                .eqIfPresent(AqiDO::getDescription, reqVO.getDescription())
                .eqIfPresent(AqiDO::getPm25Confirm, reqVO.getPm25Confirm())
                .eqIfPresent(AqiDO::getSo2Confirm, reqVO.getSo2Confirm())
                .eqIfPresent(AqiDO::getCoConfirm, reqVO.getCoConfirm())
                .eqIfPresent(AqiDO::getDescriptionConfirm, reqVO.getDescriptionConfirm())
                .eqIfPresent(AqiDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(AqiDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(AqiDO::getGridId, reqVO.getGridId())
                .likeIfPresent(AqiDO::getGridName, reqVO.getGridName())
                .eqIfPresent(AqiDO::getAqiLevel, reqVO.getAqiLevel())
                .eqIfPresent(AqiDO::getAqiLevelConfirm, reqVO.getAqiLevelConfirm())
                .eqIfPresent(AqiDO::getAqi, reqVO.getAqi())
                .eqIfPresent(AqiDO::getAqiConfirm, reqVO.getAqiConfirm())
                .orderByDesc(AqiDO::getId));
    }

    List<Map> selectAqiWithProvince();
}